//
//  LTFindViewController.m
//  聆听FM
//
//  Created by dllo on 16/6/6.
//  Copyright © 2016年 Dark. All rights reserved.
//

#import "LTFindViewController.h"
#import "LJLClassificationPageViewController.h"
#import "LJLRadioPageViewController.h"
#import "YWAnchorViewController.h"
#import "YWHotListViewController.h"
#import "ZCSRecommendViewController.h"
#import "YWSearchViewController.h"
#import "LJLMyVC.h"


@interface LTFindViewController ()

@end

@implementation LTFindViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"搜索"] imageWithRenderingMode:1] style:UIBarButtonItemStylePlain target:self action:@selector(pushSearch:)];
    
    UIButton *searchButton = [UIButton buttonWithType:UIButtonTypeSystem];
    searchButton.frame = CGRectMake(15, 29, 24, 24);
    [searchButton setImage:[UIImage imageNamed:@"搜索"] forState:UIControlStateNormal];
    [searchButton setTintColor:[UIColor whiteColor]];
    [self.view addSubview:searchButton];
    [searchButton addTarget:self action:@selector(pushSearch:) forControlEvents:UIControlEventTouchUpInside];
    
    UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(50 * FITWIDTH, 29, 275 * FITWIDTH, 30)];
    titleView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:titleView];
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:titleView.bounds];
    titleLabel.text = @"聆听FM";
    titleLabel.textAlignment = 1;
    titleLabel.textColor = [UIColor whiteColor];
    titleLabel.font = [UIFont fontWithName:@"Arial Hebrew" size:20];
    [titleView addSubview:titleLabel];
    
    UIButton *me = [UIButton buttonWithType:UIButtonTypeSystem];
    me.frame = CGRectMake(SCREENWIDTH - 39, 29, 24, 24);
    [me setImage:[UIImage imageNamed:@"我的"] forState:UIControlStateNormal];
    [me setTintColor: [UIColor whiteColor]];
    [self.view addSubview:me];
    
    
    [me addTarget:self action:@selector(didMeVc) forControlEvents:UIControlEventTouchUpInside];

}
- (void)didMeVc
{
    LJLMyVC *myVc = [[LJLMyVC alloc] init];
    myVc.hidesBottomBarWhenPushed = YES;
    CGContextRef context = UIGraphicsGetCurrentContext();
    [UIView beginAnimations:nil context:context];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.6];
    [self.navigationController pushViewController:myVc animated:NO];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:YES];
    [UIView commitAnimations];
}

- (void)pushSearch:(UIButton *)sender
{
    YWSearchViewController *svc = [[YWSearchViewController alloc] init];
    svc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:svc animated:YES];
}


+ (UINavigationController *)defaultFindUINavigationController
{
    static UINavigationController *nav = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        LTFindViewController *findVC = [[LTFindViewController alloc] initWithViewControllerClasses:[self ViewControllerClasses] andTheirTitles:@[@"推荐",@"分类",@"广播",@"榜单",@"主播"]];
        //WMPageController的设置
        findVC.menuViewStyle = WMMenuViewStyleLine;
        // 设置每个item的宽
        findVC.itemsWidths = @[@(SCREENWIDTH/5),@(SCREENWIDTH/5),@(SCREENWIDTH/5),@(SCREENWIDTH/5),@(SCREENWIDTH/5)];
        //选中时标题颜色:
        findVC.titleColorSelected = [UIColor whiteColor];
        //未选中标题颜色:
        findVC.titleColorNormal = [UIColor colorWithWhite:0.802 alpha:1.000];
        //下划线进度条高度:
        findVC.progressHeight = 2;
        //设置选中不改变大小:
        findVC.titleSizeSelected = 17;
        //设置假导航栏颜色:
        findVC.menuBGColor = [UIColor clearColor];
        //设置发现页面frame:
        findVC.viewFrame = CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT - 64 - 49);
        findVC.startDragging = YES;
        nav = [[UINavigationController alloc] initWithRootViewController:findVC];
    });
    return nav;
}


#pragma mark -- 得到发现页的所有页控制器数组
+ (NSArray *)ViewControllerClasses {
    return @[[ZCSRecommendViewController class],[LJLClassificationPageViewController class] ,[LJLRadioPageViewController class],[YWHotListViewController class],[YWAnchorViewController class]];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
